//
//  NetDataProvider.m
//  Ghac 4S
//
//  Created by apple on 11-9-5.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "NetDataProvider.h"
#import "KURL.h"

@implementation NetDataProvider
-(void)loadDataWithResource:(NSString *)source
{
    KURLLoader* loader = [[KURLLoader alloc] initWithDelegate:self];
    NSURL* url = [[NSURL alloc] initWithString:source];
    
    KURLRequest* request = [[KURLRequest alloc] initWithURL:url];
    [loader addEventListener:KLOADER_COMPLETE sector:@selector(loadComplete:)];
    [loader addEventListener:KLOADER_ERROR sector:@selector(loadError:)];
    NSLog(@"load %@", source);
    [loader load:request];
    [request release];
    [url release];
    [loader release];
}
-(void) loadComplete:(id)sender
{
    [self.deletageTarget onData:((KURLLoader*)sender).data];
}
-(void) loadError:(id)sender
{
    [self.deletageTarget onError:Nil];
}
@end
